const axios = require('axios');
const MockAdapter = require('axios-mock-adapter');
const normalAxios = axios.create();
const mockAxios = axios.create();
import _config from "./config";
import reqTools from "../utils/reqTools";

// mock 数据
var mock = new MockAdapter(mockAxios);

mock.onGet('/getWithdraw').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.get('/api/withdraw',config.params).then(res => {
      resolve([200, res.data]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});


mock.onGet('/queryWallet').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.get('/api/sysOffice/queryWallet',config.params).then(res => {
      resolve([200, res.data]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});

mock.onPost('/addWithdraw').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.post( '/api/withdraw',config.data
    ).then((res) => {
      resolve([200, res]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});
mock.onPut('/updateWithdraw').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.put( '/api/withdraw', config.data, 
   ).then((res) => {
      resolve([200, res ]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});

//代理商收支明细
mock.onGet('/balancelog/all').reply((config) => {
  return new Promise(function(resolve, reject) {
    reqTools.get('/api/sysofficebalancelog',config.params).then(res => {
      resolve([200, res.data]);
    }).catch((err) => {
      resolve([500, err ]);
    });
  });
});
export default mockAxios;
